<?php
//if (isset($_SESSION['username'])) {
include_once 'header.php';
require_once("conn.php");
$db = new DBC();

$is_exist = false;
$type = "";
if (isset($_GET['flashcode'])) {
    $flashcode = $_GET['flashcode'];
    $sql = "SELECT * FROM t_try WHERE flashcode = '" . $flashcode . "'";
    $data = $db->fetchData($sql);
    if ($data != false && count($data) > 0) {
        $is_exist = true;
        $type = $data[0]['type'];
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>乐知家园</title>
        <style type="text/css">
            <!--
            body,td,th {
                font-family: 微软雅黑;
                font-size: 14px;
                color: #CCCCCC;
            }

            .text{
                height:20px;				
            }
            .disable{
                background-color:#CCCCCC;
            }
            -->
        </style>
        <script language="javascript">
            function onchange_age(){
                var obj = document.getElementById("age");
                var age = obj.options[obj.selectedIndex].value;
				
            }
			
            function onSubmitCheck(){
                var flashcode = document.getElementById("flashcode").value;
                var flashname = document.getElementById("flashname").value;
                var type2 = document.getElementsByName("type2[]");
                var version = document.getElementById("version").value;
                var apkurl = document.getElementById("apkurl").value;
                var isok = true;
                var ischecked = false;
                for(var i=0;i<type2.length;i++){
                    if(type2[i].checked==true){
                        ischecked = true;
                        break;
                    }
                }
                if(flashcode==""){
                    alert("\u8bf7输入编码");
                    isok = false;
                }else if(flashname==""){
                    alert("\u8bf7输入名称");
                    isok = false;	
                }else if(version==""){
                    al\u8bf7rt("\u8bf7输入版本");
                    isok = false;	
                }else if(apkurl==""){
                    al\u8bf7rt("\u8bf7输入应用地址");
                    isok = false;															
                }else if(!ischecked){
                    al\u8bf7rt("\u8bf7至少选择一项\u80fd力");
                    isok = false;
                }
                if(!isok){
                    event.returnValue = false;
                }
            }
        </script>
        <script type="text/javascript" src="js/jQuery.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                $("#age").change(function(){
                    $.get("getPackByAge.php?age=1", function(data){
                        var obj = jQuery.parseJSON(data);                        
                        $('#packselect').children().remove().end();
                        $("#packselect").append('<option value="-1">\u65e0</option>');
                        for(var i=0;i<obj.length;i++){                        
                            var option = "<option value="+obj[i].packid+">"+obj[i].packcode+"-"+obj[i].name+"</option>";
                            $("#packselect").append(option);
                        }
                    });			
                });
            });
        </script>
    </head>

    <body>
        <form id="form1" name="form1" method="post" action="try.action.php" enctype="multipart/form-data">
            <table width="50%" border="0" align="center" cellpadding="1" cellspacing="1">
                <tr>
                    <td height="30" bgcolor="#666666"> 应用编码</td>
                    <td bgcolor="#9999FF"><input name="appflashcode" type="text" size="50" class="disable" value="<?php echo $flashcode; ?>" disabled="disabled"/>
                    <input id="flashcode" name="flashcode" type="hidden" value="<?php echo $flashcode; ?>"/>
                    <input name="isModify" type="hidden" value="<?php echo $is_exist; ?>"/>
                    </td>
                </tr>
                <tr>
                    <td height="30" bgcolor="#666666">试玩次数</td>
                    <td bgcolor="#9999FF"><input name="playTimes" type="text" size="50" class="disable" value="<?php echo $is_exist ? $data[0]['playTimes'] : 0; ?>" disabled="disabled" /></td>
                </tr>
                <tr>
                    <td height="30" bgcolor="#666666">图标</td>
                    <td bgcolor="#9999FF"><input name="imageURL" type="file" size="50" class="text" value="<?php echo $is_exist ? $data[0]['imageURL'] : ""; ?>"/></td>
                </tr>
                <tr>
                    <td height="30" bgcolor="#666666">名称</td>
                    <td bgcolor="#9999FF"><input name="name" type="text" size="50" class="text" value="<?php echo $is_exist ? $data[0]['name'] : ""; ?>"/></td>
                </tr>                
                <tr>
                    <td height="30" bgcolor="#666666">类型</td>
                    <td bgcolor="#9999FF">
                        <input name="type" type="radio" class="text" <?php if (stristr($type, '1') || $type == "") { ?> checked="checked" <?php } ?> value="1" />动画故事&nbsp;
                        <input name="type" type="radio" class="text" <?php if (stristr($type, '2')) { ?> checked="checked" <?php } ?> value="2"/>互动学习&nbsp;
                        <input name="type" type="radio" class="text" <?php if (stristr($type, '3')) { ?> checked="checked" <?php } ?> value="3"/>益智游戏</td>
                </tr>                
                <tr>
                    <td height="30" bgcolor="#666666">地址</td>
                    <td bgcolor="#9999FF"><input id="url" name="url" type="text" size="50" class="text" value="<?php echo $is_exist ? $data[0]['url'] : ""; ?>"/></td>
                </tr>
                <tr>
                    <td height="30" bgcolor="#666666">版本</td>
                    <td bgcolor="#9999FF"><input id="version" name="version" type="text" size="50" class="text" value="<?php echo $is_exist ? $data[0]['version'] : ""; ?>"/></td>
                </tr>                			                				
                <tr>
                    <td height="30" bgcolor="#666666">系统需求</td>
                    <td bgcolor="#9999FF"><input id="requirement" name="requirement" type="text" size="50" class="text" value="<?php echo $is_exist ? $data[0]['requirement'] : ""; ?>"/></td>
                </tr>
                <tr>
                    <td height="30" bgcolor="#666666">推荐分辨率</td>
                    <td bgcolor="#9999FF"><input id="resolution" name="resolution" type="text" size="50" class="text" value="<?php echo $is_exist ? $data[0]['resolution'] : ""; ?>"/></td>
                </tr>
                <tr>
                    <td height="30" bgcolor="#666666">创建时间</td>
                    <td bgcolor="#9999FF"><input id="createTime" name="createTime" type="text" size="50" class="disable" disabled="disabled" value="<?php echo $is_exist ? $data[0]['createTime'] : ""; ?>"/></td>
                </tr>
                <tr>
                    <td height="30" bgcolor="#666666">&nbsp;</td>
                    <td bgcolor="#9999FF">
                        <input type="submit" name="Submit" value="提交" onclick="onSubmitCheck()" />                    </td>
                </tr>
            </table>
        </form>
    </body>
</html>
<?php

function has($type, $num) {
    if (strpos($type, $num) >= 0) {
        return true;
    }
    return false;
}

include_once 'footer.php';
//} else {
//    header("login.php");
//}
?>
